package com.dunhor.feign.consumer.controllor;

import com.dunhor.feign.consumer.enty.User;
import com.dunhor.feign.consumer.interf.HelloService;
import com.dunhor.feign.consumer.interf.RefactorHelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConsumerController {

    @Autowired
    HelloService helloService;
    @Autowired
    RefactorHelloService refactorHelloService;

    @RequestMapping(value = "/feign-consumer",method = RequestMethod.GET)
    public String helloConsumer(){
        return helloService.hello();
    }

    @RequestMapping(value = "/feign-consumer2",method = RequestMethod.GET)
    public String helloConsumer2(){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(helloService.hello()).append("\n");
        stringBuilder.append(helloService.hello("DIDI")).append("\n");
        stringBuilder.append(helloService.hello("DIDI",30)).append("\n");
        stringBuilder.append(helloService.hello(new User("DIDI",30))).append("\n");
        return stringBuilder.toString();
    }

    @RequestMapping(value = "/feign-consumer3",method = RequestMethod.GET)
    public String helloConsumer3(){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(refactorHelloService.hello("MIMI")).append("\n");
        stringBuilder.append(refactorHelloService.hello("MIMI",30)).append("\n");
        stringBuilder.append(refactorHelloService.hello(new com.dunhor.hello.service.api.entry.User("MIMI",30))).append("\n");
        return stringBuilder.toString();
    }
}
